package o;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import androidx.annotation.NonNull;
import com.huawei.appgallery.appcomment.api.UserCommentListActivityProtocol;
import com.huawei.appgallery.appcomment.api.UserCommentListActivityProtocol.Request;
import com.huawei.appgallery.appcomment.impl.bean.CommentsCache;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;
import java.util.List;
import o.bcg.b;

public class ber {
    public static boolean ˊ(Context context) {
        return context.getResources().getConfiguration().orientation == 2;
    }

    public static void ˎ(@NonNull View view) {
        if (view.getContext() != null) {
            azb.ˋ(view, view.getContext().getResources().getDimensionPixelSize(b.ᐝ), view.getContext().getResources().getDimensionPixelSize(b.ʼ));
        }
    }

    public static void ˋ(@NonNull View view) {
        if (view.getContext() != null) {
            azb.ˋ(view, (view.getContext().getResources().getDimensionPixelSize(b.ᐝ) + view.getContext().getResources().getDimensionPixelSize(b.ʽ)) + view.getContext().getResources().getDimensionPixelSize(b.ʻ), view.getContext().getResources().getDimensionPixelSize(b.ʼ));
        }
    }

    public static int ॱ(View view) {
        if (view.getContext() == null) {
            return 0;
        }
        int ˊ = azb.ˊ(view.getContext());
        return (azb.ॱ(view.getContext()) - ˊ) - azb.ˏ(view.getContext());
    }

    public static int ˏ(View view) {
        if (view.getContext() == null) {
            return 0;
        }
        int dimensionPixelSize = view.getContext().getResources().getDimensionPixelSize(b.ᐝ);
        return (azb.ॱ(view.getContext()) - dimensionPixelSize) - view.getContext().getResources().getDimensionPixelSize(b.ʼ);
    }

    public static String ˋ(Context context, String str) {
        PackageManager packageManager = context.getPackageManager();
        try {
            CharSequence applicationLabel = packageManager.getApplicationLabel(packageManager.getApplicationInfo(str, DnsConfig.MAX_CACHE_ENTRIES));
            if (applicationLabel != null) {
                return applicationLabel.toString();
            }
        } catch (NameNotFoundException e) {
            bcb.ˋ.ˊ("CommentUtil", "NameNotFoundException: " + e.toString());
        }
        return null;
    }

    public static Bundle ॱ(bch o_bch) {
        PackageInfo ᐝ;
        String str;
        String valueOf;
        if (o_bch.ॱ() != null) {
            ᐝ = ((cdg) cdb.ॱ(cdg.class)).ᐝ(o_bch.ॱ());
        } else {
            ᐝ = null;
        }
        if (ᐝ != null) {
            str = ᐝ.versionName;
            valueOf = String.valueOf(ᐝ.versionCode);
        } else {
            str = o_bch.ˎ();
            valueOf = o_bch.ˎ();
        }
        Bundle bundle = new Bundle();
        bundle.putString("APP_NAME", o_bch.ˋ());
        bundle.putString("APP_ICON", o_bch.ˊ());
        bundle.putString("APP_ID", o_bch.ˏ());
        bundle.putString("PACKAGE_NAME", o_bch.ॱ());
        bundle.putString("VERSION_CODE", valueOf);
        bundle.putString("VERSION_NAME", str);
        bundle.putBoolean("IS_APPZONE_COMMENT", o_bch.ॱॱ());
        bundle.putInt("LIST_ID", o_bch.ʽ());
        float f = 0.0f;
        List ˊ = bdc.ˊ().ˊ(o_bch.ˏ(), valueOf);
        if (ˊ == null || ˊ.isEmpty()) {
            float parseFloat;
            if (!TextUtils.isEmpty(o_bch.ʼ())) {
                try {
                    parseFloat = Float.parseFloat(o_bch.ʼ());
                } catch (Throwable e) {
                    bcb.ˋ.ˊ("CommentUtil", "newInstance error", e);
                }
                bundle.putString("COMMENT_CONTENT", o_bch.ᐝ());
                f = parseFloat;
            }
            parseFloat = 0.0f;
            bundle.putString("COMMENT_CONTENT", o_bch.ᐝ());
            f = parseFloat;
        } else {
            bundle.putString("COMMENT_CONTENT", cev.ˎ(((CommentsCache) ˊ.get(0)).ˊ()));
        }
        if (ᐝ != null) {
            bundle.putString("COMMENT_ID", o_bch.ʻ());
        }
        bundle.putFloat("COMMENT_RATING", f);
        return bundle;
    }

    public static String ˊ() {
        try {
            return ContentManager.getInstant().getContext().getPackageManager().getPackageInfo(ContentManager.getInstant().getContext().getPackageName(), DnsConfig.MAX_CACHE_ENTRIES).versionName;
        } catch (Throwable e) {
            bcb.ˋ.ˊ("CommentUtil", "getVersionCode error.", e);
            return "";
        }
    }

    public static int ॱ() {
        try {
            return ContentManager.getInstant().getContext().getPackageManager().getPackageInfo(ContentManager.getInstant().getContext().getPackageName(), DnsConfig.MAX_CACHE_ENTRIES).versionCode;
        } catch (Throwable e) {
            bcb.ˋ.ˊ("CommentUtil", "getVersionCode error.", e);
            return 0;
        }
    }

    public static void ॱ(String str, Context context) {
        cjo userCommentListActivityProtocol = new UserCommentListActivityProtocol();
        Request request = new Request();
        request.ˏ(str);
        userCommentListActivityProtocol.ˎ(request);
        cjk.ˎ().ˋ(context, new cjm("usercomment.activity", userCommentListActivityProtocol));
    }
}
